﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
   public class UserDDDAL
    {
        public static UserDD gatall(string name,string pwd)
        {
            var sql = $"select * from UserDD where UserName='{name}' and UserPwd='{pwd}'";
            var table = DBheper.Query(sql);
            //如果没有数据
            if (table == null || table.Rows.Count < 1)
            {
                return null;
            }
            //如果有数据,取第一行，转换为对象
            var row = table.Rows[0];
            UserDD user = new UserDD()
            {
                UserID = Convert.ToInt32(row["UserID"]),
               UserName = Convert.ToString(row["UserName"]),
                role = Convert.ToInt32(row["role"])



            };
            return user;
         
        }
        
    }
    
}
